package com.xp.tinyurl.common.enums;

/**
 * @description 短链接有效期过期枚举
 * @author xp
 * @since 2.0.0
 * @date 2019/09/29 11:00
 */
public enum ExpiredEnum {

    ONE_DAY(1, "一天"),

    THREE_MONTHS(2, "三个月"),

    ONE_YEAR(3, "一年"),

    FOREVER(4, "永久"),
    ;

    private Integer index;
    private String name;

    ExpiredEnum(int i, String d) {
        this.index = i;
        this.name = d;
    }

    public int getIndex() {
        return this.index;
    }

    public String getName() {
        return this.name;
    }

    public static ExpiredEnum getByCode(Integer idx){
        if(idx == null){
            return null;
        }
        for(ExpiredEnum expiredEnum : ExpiredEnum.values()){
            if(expiredEnum.getIndex() != idx.intValue()){
                continue;
            }
            return expiredEnum;
        }
        return null;
    }

}
